/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_conditional_action.h

	$Header: /heroes4/script_conditional_action.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_CONDITIONAL_ACTION_H_INCLUDED )
#define SCRIPT_CONDITIONAL_ACTION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <cassert>
#include <iosfwd>

#include "abstract_script_expression.h"
#include "script_branch_action.h"

// --------------------------------------------------------------------------
// t_script_conditional_action class
// --------------------------------------------------------------------------

class t_script_conditional_action : public t_script_branch_action
{
public:
	// Types
	typedef t_abstract_script_boolean_expression	t_condition;

	// Member functions
	virtual void		execute(t_script_context_hero const& context) const;
	virtual void		execute(t_script_context_town const& context) const;
	virtual void		execute(t_script_context_object const& context) const;
	virtual void		execute(t_script_context_army const& context) const;
	virtual void		execute(t_script_context_global const& context) const;

	t_condition const &	get_condition() const;

	virtual bool		read( std::streambuf& stream, int version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf& stream ) const;


private:
	// Data members
	t_counted_ptr< t_condition > m_condition_ptr;
};

// --------------------------------------------------------------------------
// t_script_conditional_action inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_conditional_action::t_condition const &
t_script_conditional_action::get_condition() const
{
	assert( m_condition_ptr.get() != 0 );
	return *m_condition_ptr;
}

SPECIALIZE_SCRIPT_ACTION( k_script_action_conditional, t_script_conditional_action );

#endif // !defined( SCRIPT_CONDITIONAL_ACTION_H_INCLUDED )
